<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ include file="/page/public/public-taglibs.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
<%@ include file="/page/public/public-css.jsp"%>
</head>
<body class="no-skin">
	<div class="main-container" id="main-container">

		<!-- /section:basics/sidebar -->
		<div class="main-content">
			<div class="main-content-inner">
				<div class="page-content">
					<div class="row">
						<!-- /.page-header -->
						<div class="col-xs-12 col-sm-12 widget-container-col">
							<div class="widget-box widget-color-green">
								<!-- #section:custom/widget-box.options -->
								<div class="widget-header">
									<h5 class="widget-title">
										<i class="ace-icon fa fa-filter bigger-130"></i>查询内容
									</h5>
									<div class="widget-toolbar no-border"
										style="padding-top: 10px;">
										<a href="#" data-action="collapse" class="orange2"> <i
											class="1 ace-icon fa fa-chevron-up bigger-125 "></i>
										</a>
									</div>
									<div class="widget-toolbar no-border">

										<button class="btn btn-xs btn-yellow" onClick="doQuery();">
											<i class="ace-icon fa fa-search icon-on-left"></i>查询
										</button>

										<button class="btn btn-xs btn-light " onClick="doQueryReset();">
											<i class="ace-icon fa fa-refresh"></i> 重置
										</button>

									</div>
								</div>

								<!-- /section:custom/widget-box.options -->
								<div class="widget-body">
									<div class="widget-main">
										<div class="clearfix">
											<div class="row">
												<div class="col-xs-12">
													<!-- PAGE CONTENT BEGINS -->
													<form id='queryForm' class="form-horizontal" role="form">
														<div class="form-group col-sm-3">
															<label class="col-sm-4 control-label no-padding-right">用户帐号</label>
															<div class="col-sm-8">
																<input type="text" name="username"
																	class="col-xs-10 col-sm-12 input-sm" />
															</div>
														</div>

														<div class="form-group col-sm-3">
															<label class="col-sm-4 control-label no-padding-right">手机号码</label>
															<div class="col-sm-8">
																<input type="text" name="mobile"
																	class="col-xs-10 col-sm-12 input-sm" />
															</div>
														</div>

														<div class="form-group col-sm-3">
															<label class="col-sm-4 control-label no-padding-right">邮箱地址</label>
															<div class="col-sm-8">
																<input type="text" name="email"
																	class="col-xs-10 col-sm-12 input-sm" />
															</div>
														</div>

														<div class="form-group col-sm-3">
															<label class="col-sm-4 control-label no-padding-right">是否可用</label>
															<div class="col-sm-8">
																<fas:select list="$AVAILABLE" name="available"
																	cssClass="form-control input-sm" emptyOption="true"
																	headerKey="请选择" headerValue="" />

															</div>
														</div>
													</form>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<!-- /.span -->
					</div>
					<!-- /.row -->



					<div class="row">
						<!-- /.page-header -->
						<div class="col-xs-12 col-sm-12 widget-container-col">
							<div class="widget-box widget-color-green">
								<!-- #section:custom/widget-box.options -->
								<div class="widget-header">
									<h5 class="widget-title">
										<i class="ace-icon fa fa-table bigger-130"></i>数据列表
									</h5>

									<div class="widget-toolbar no-border"
										style="padding-top: 10px;">
										<a href="#" data-action="fullscreen" class="orange2"> <i
											class="ace-icon fa fa-expand bigger-125"></i>
										</a>
									</div>

									<div class="widget-toolbar no-border">
										<!-- 
										<button class="btn btn-xs btn-white btn-default ">
											<i class="ace-icon fa fa-plus bigger-120 blue"></i> 新增
										</button>

										<button class="btn btn-xs btn-white btn-default ">
											<i class="ace-icon fa fa-edit bigger-120 orange"></i> 修改
										</button>
										
										<button class="btn btn-xs btn-white btn-default ">
											<i class="ace-icon fa fa-file-text bigger-120 purple"></i> 查看
										</button>

										<button class="btn btn-xs  btn-white btn-default ">
											<i class="ace-icon fa fa-trash-o bigger-120 red2"></i> 删除
										</button>

										<button class="btn btn-xs btn-white btn-default ">
											<i class="ace-icon fa fa-refresh bigger-120 green"></i> 刷新
										</button>
										 -->

										<span style="padding-left: 20px;" onclick="doAdd();"> <i
											class="ace-icon fa fa-plus bigger-120 "></i> 新增
										</span> <span style="padding-left: 20px;"> <i
											class="ace-icon fa fa-edit bigger-120 "></i> 修改
										</span> <span style="padding-left: 20px;"> <i
											class="ace-icon fa fa-file-text bigger-120 "></i> 查看
										</span> <span style="padding-left: 20px;"> <i
											class="ace-icon fa fa-trash-o bigger-120 "></i> 删除
										</span> <span style="padding-left: 20px;"> <i
											class="ace-icon fa fa-refresh bigger-120 "></i> 刷新
										</span>


									</div>
								</div>

								<!-- /section:custom/widget-box.options -->
								<div class="widget-body">
									<div class="widget-main"
										style="padding-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px;">
										<div class="clearfix">
											<div class="row">
												<div class="col-xs-12">
													<table id="dataTable" style="width: 100%"
														class="table table-striped table-bordered table-hover form-inline">
													</table>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<!-- /.span -->
					</div>
					<!-- /.row -->
				</div>
			</div>
		</div>
	</div>

	<%@ include file="/page/public/public-js.jsp"%>
	<script type="text/javascript">
		$(function() {
			var initAction = function() {
				cmdList = ctx + "/system/user/list";
				cmdAdd = ctx + "/system/user/add?ISNEW=true"; //新增
				cmdView = ctx + "/system/user/view?PK={0}";//查看
				cmdEdit = ctx + "/system/user/edit?PK={0}";//查看
				cmdDelete = ctx + "/system/user/delete?PK={0}";//删除
			}

			var initDataTable = function() {
				dataTable = $('#dataTable')
						.dataTable(
								{
									//数据列控制（包括对应返回JSON属性名称，对应表头列索引位置、数据转换封装等）
									"aoColumnDefs" : [
											{
												"sTitle" : "用户ID", //列名
												"sName" : "id", //库表字段名
												"mData" : "id", //JSON返回属性
												"aTargets" : [ 0 ], //第几列
												"bVisible" : false, //px 或者 %
												"bSortable" : true
											//是否排序，默认排序
											},
											{
												"sTitle" : "用户帐号",
												"sName" : "username",
												"mData" : "username",
												"aTargets" : [ 1 ],
												"bVisible" : true,
												"bSortable" : false
											},
											{
												"sTitle" : "姓名",
												"sName" : "username_zh",
												"mData" : "username_zh",
												"aTargets" : [ 2 ],
												"bSortable" : false
											},
											{
												"sTitle" : "手机号码",
												"sName" : "mobile",
												"mData" : "mobile",
												"aTargets" : [ 3 ],
												"bVisible" : true,
												"bSortable" : false
											},
											{
												"sTitle" : "电子邮箱",
												"sName" : "email",
												"mData" : "email",
												"aTargets" : [ 4 ],
												"bSortable" : false
											},
											{
												"sTitle" : "所属机构",
												"sName" : "org_full_path",
												"mData" : "org_full_path",
												"aTargets" : [ 5 ],
												"bSortable" : false
											},
											{
												"sTitle" : "是否可用",
												"sName" : "available",
												"mData" : "available",
												"aTargets" : [ 6 ],
												"bSortable" : true,
												"mRender" : function(value,
														type, row) {
													return ParamTool
															.getTranHtml(
																	"AVAILABLE",
																	value);
												}
											},
											{
												"sTitle" : "操作",
												"sName" : "id",
												"mData" : "id",
												"aTargets" : [ 7 ],
												"bSortable" : false,
												"mRender" : function(value,
														type, row) {
													var html = "";
													html += '<a style="padding-left:15px" href="javaScript:void(0)" title="查看" onclick="Javascript:doViewByPK(\''
															+ value
															+ '\');"><i class="fa  fa-search-plus bigger-130"></i>&nbsp;查看</a>';
													html += '<a style="padding-left:15px" href="javaScript:void(0)" title="修改" onclick="Javascript:doEditByPK(\''
															+ value
															+ '\');"><i class="fa fa-edit bigger-130"></i>&nbsp;修改</a>';
													html += '<a style="padding-left:15px" href="javaScript:void(0)" title="删除" onclick="Javascript:doDeleteUserByPk(\''
															+ value
															+ '\');"><i class="fa fa-trash-o bigger-130"></i>&nbsp;删除</a>';
													return html;
												}
											} ],
									"aaSorting" : [ [ 3, "desc" ] ],//初始化加载，默认按第几列排序、排序方式（列从0开始计算）
									"sAjaxSource" : cmdList
								//数据源URL
								});
			}
			initAction();
			initDataTable();
		});
		
		function doDeleteUserByPk(userId){
			top.bootbox.confirm("确定要删除用户?", function(
					result) {
				if (result) {
					var url = ctx + "/system/user/delete";
					url = addParam(url, "userId", userId);
					$.ajax({
						type : 'POST',
						url : url,
						dataType : "json",
						success : function(response) {
							if (response.status == RESULT_SUCCESS) {
								doQuery();
							} else {
								handleAjaxError(response);
							}
						}
					});
				}
			});
		}
	</script>
</body>
</html>